package com.hulu.yec.sys.yecclass.service;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ClassDeleteDao {

	/**
	 * 增加和修改、查询
	 * 
	 * @param sql
	 * @return
	 * @throws SQLException
	 */
	public static int states(String sql) throws SQLException {

		Connection connection = null;
		PreparedStatement preparedStatement = null;
		ResultSet resultSet = null;

		try {
			Class.forName("com.mysql.jdbc.Driver");
			connection = DriverManager.getConnection(
					"jdbc:mysql://localhost:3306/exam", "root", "root");

			preparedStatement = connection.prepareStatement(sql);

			return preparedStatement.executeUpdate(sql);

		} catch (ClassNotFoundException | SQLException e) {
			throw new RuntimeException("简历查询失败~");
		} finally {
			// 4、资源关闭

			if (resultSet != null) {
				resultSet.close();
			}
			if (preparedStatement != null) {
				preparedStatement.close();
			}
			if (connection != null) {
				connection.close();
			}

		}

	}
}
